import VideoPlayer from 'react-native-video-controls'
import React, {Component} from 'react'
import {fsReadPath} from '../../helpers/fsHelper'
import Loading from './loading_common'

class VideoBrowserScene extends Component {

    constructor (props) {
      super(props);
      this.state = {
        uri: props.navigation.state.params.uri,
        loading: true
      }
    }

    async componentDidMount () {
      let _uri = await fsReadPath(this.state.uri)
      this.setState({
        loading: false,
        uri: _uri
      })
    }

    render () {
      const {uri, loading} = this.state
      if (loading == true) {
        return <Loading />
      } else {
        return (
          <VideoPlayer
              source={{ uri: uri }}
              disableBack={ true } 
          />
        )
      }
    }
}

export default VideoBrowserScene